/*
 * CDeviceManager.h
 *
 * Un classe de gestion des devices de VRJugler
 */

#ifndef CDEVICEMANAGER_H_
#define CDEVICEMANAGER_H_

#include "CButton.h"
#include <string>
#include <vector>

#include <gadget/Type/Position/PositionUnitConversion.h>
#include <gadget/Type/PositionInterface.h>
#include <gadget/Type/AnalogInterface.h>
#include <gadget/Type/DigitalInterface.h>
#include <gmtl/Vec.h>
#include <gmtl/Coord.h>
#include <gmtl/Xforms.h>
#include <gmtl/Math.h>

#include <osg/Matrix>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osgUtil/SceneView>

class CDeviceManager{
private:
	gadget::PositionInterface  _Wand;     // la Wand
	gadget::PositionInterface  _Head; // La tête
	osg::Vec3 _wandPosition;	// La position de la wand
	osg::Vec3 _headPosition; // La position de la tête
	std::vector<CButton *> _buttons; // Les boutons
	bool _recordWandMovement;
	osg::Vec3 _wandMovement;
	vpr::Interval _last_frame; // Le temps de la derniere frame

	void updateWandPosition(float drawFactor);
	void updateHeadPosition(float drawFactor);

public:
	CDeviceManager();
	~CDeviceManager();

	void init();
	void addButton(std::string name);
	CButton* getButton(int i);
	int getButtonNb(){ return _buttons.size(); }
	osg::Vec3 getWandPosition() { return _wandPosition; }
	osg::Vec3 getHeadPosition() { return _headPosition; }
	float getDeltaTime();
	osg::Vec3 getWandMovement();
	void updateDevices(float drawFactor);
	void startRecordWandMovement();
	void stopRecordWandMovement();
};

#endif
